package ai.people.core.common.properties.elastic;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 社交媒体账号注册信息ES索引映射关系
 *
 * @author liguannan
 * @date 2022/6/9 13:28
 */
@Component
@ConfigurationProperties(prefix = "elastic.social.media.register")
public class ElasticSocialMediaRegisterInfoIndex {

    public void setIndexMap(Map<String, String> indexMap) {
        this.indexMap = indexMap;
    }

    private static Map<String, String> indexMap;

    public static String getIndexBySource(String source){
        return indexMap.get(source);
    }

    public static String[] getIndexListBySources(List<String> sources){
        return sources.stream().map(o->indexMap.get(o)).collect(Collectors.toList()).toArray(new String[]{});
    }
}
